package com.weblog.user.controller;

import com.weblog.user.utils.AccessUtil;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 提供校验权限的接口
 * @author MaoLin Wang
 * @date 2019/9/2215:45
 */
@RestController
@CrossOrigin
public class AccessController {

    @Autowired
    private AccessUtil accessUtil;


    @GetMapping("/access/{targetRole}/{targetPermission}")
    public Result isAccess(@PathVariable("targetRole")String targetRole, @PathVariable("targetPermission")String targetPermission){
        int access = accessUtil.isAccess(targetRole, targetPermission);
        return new Result(true, StatusCode.OK,"鉴定成功",access);
    }
}
